#include <iostream>
#include <cstdlib>
#include <string>

using namespace std;

void LevelUp();
void Start();
void PickRace();
int Town();
    int Blacksmith();
    int Shrine();
int Menu();
void PlayerInfo();
void Explore();
void PlayerStats();

//Set stats//

    //Player
    string playerName;
    string playerRace;
    int playerHPMax = 100;
    int playerHPCur = playerHPMax;
    int playerMPMax = 100;
    int playerMPCur = playerMPMax;
    int playerMelee = 7;
    int playerLvl = 1;
    int playerGold = 100;
    int playerEXP = 0;
    int playerEXPtoLevel = 100;

    //Goblin
    int gobdrop = 7;
    int gobhp;
    int gobdmg = 3;

    //Bandit
    int bandrop = 15;
    int banhp;
    int bandmg = 5;

    //Python
    int pytdrop = 30;
    int pythp;
    int pytdmg = 13;

int main()
{
    system("title Aronia");
    system("color 2b");
    Start();
}

void Start()
{
    cout <<
    "\t\t\t      Welcome to Aronia!\n"<<
    "\t\t\t   Copyright 2011 Apex Games\n\n\n"<<
    "Please enter your name: ";

    getline (cin, playerName);
    system("CLS");
    cout <<"Hello, "<<playerName<<"!\n\n";

    PickRace();
}

void PickRace()
{
    cout <<
    "Please pick your race: \n"<<
    "1 - Human\n"<<
    "2 - Elf\n"<<
    "3 - Dwarf\n";

    int pickRace;
    cout <<"Choice: ";
    cin >> pickRace;

    switch (pickRace)
    {
        case 1:
            system("cls");
            playerRace = "Human";
            cout <<"You picked the Human race.\n";
            system("pause");
            break;
        case 2:
            system("cls");
            playerRace = "Elf";
            cout <<"You picked the Elf race.\n";
            system("pause");
            break;
        case 3:
            system("cls");
            playerRace = "Dwarf";
            cout <<"You picked the Dwarf race.\n";
            system("pause");
            break;
        default:
            system("cls");
            cout <<"You made an invalid selection!\n";
            system("pause");
            system("cls");
            PickRace();
    }

    Menu();
}


int Menu()
{
     //menu:
    system("CLS");

    if (playerEXP >= playerEXPtoLevel)
    {
        LevelUp();
    }

    PlayerInfo();
    cout <<
    "What should you do: \n"<<
    "1 - Explore\n"<<
    "2 - Visit the town\n"<<
    "3 - Player info\n"<<
    "0 - Exit game\n\n";

    int pickMenu;
    cout <<"Decide: ";
    cin >> pickMenu;

    switch (pickMenu)
    {
        case 0:
            return 0;
        case 1:
            Explore();
            break;
        case 2:
            Town();
            break;
        case 3:
            PlayerStats();
            break;
        default:
            cout <<"You made an invalid selection!\n";
            system("PAUSE");
            Menu();
        }
}

void PlayerStats()
{
        system("cls");
        cout
        <<"------------ Character Sheet ------------\n"
        <<"Name:   "<<playerName<<"\n"
        <<"Race:   "<<playerRace<<"\n"
        <<"Level:  "<<playerLvl<<"\n\n"

        <<"Health: "<<playerHPCur<<"/"<<playerHPMax<<"\n"
        <<"Mana:   "<<playerMPCur<<"/"<<playerMPMax<<"\n\n"

        <<"EXP:    "<<playerEXP<<"/"<<playerEXPtoLevel<<"\n"
        <<"Gold:   "<<playerGold<<"\n\n";
        system("pause");
        Menu();
}

int Town()
{
    system("cls");
    PlayerInfo();
    cout <<
    "Welcome to the town!\n\n"<<
    "What should you do: \n"<<
    "1 - Blacksmith\n"<<
    "2 - Visit the magic shrine\n"<<
    "0 - Exit town\n\n";

    int pickMenu;
    cout <<"Decide: ";
    cin >> pickMenu;

    switch (pickMenu)
    {
        case 0:
            Menu();
        case 1:
            Blacksmith();
        case 2:
            Shrine();
        default:
            cout <<"\nYou made an invalid selection!\n";
            system("PAUSE");
            Town();
    }
}

void LevelUp()
{
    playerLvl +=1;
    cout <<"You leveled up!\n\n";
    cout <<"You are now level "<<playerLvl<<"!\n";
    playerEXPtoLevel = playerLvl*65*playerLvl;
}

void PlayerDie()
{
    system("cls");
    cout <<"You have died...\n\n";
    system("pause");
}

int Blacksmith()
{
    system("cls");
    PlayerInfo();
    cout <<
    "Welcome to the blacksmith.\n\n"<<
    "What should you do: \n"<<
    "1 - Sharpen weapon (30 gold)\n"<<
    "0 - Exit\n\n";

    int pickMenu;
    cout <<"Decide: ";
    cin >> pickMenu;

    switch(pickMenu)
    {
        case 0:
            Town();
        case 1:
            if(playerGold > 30)
            {
            playerGold -= 30;
            system("cls");
            cout <<"Weapon sharpened!\n\n";
            system("pause");
            Blacksmith();
            }else{
            system("cls");
            cout << "You do not have enough gold!\n\n";
            system("pause");
            Blacksmith();
            }
        default:
            cout <<"\nYou made an invalid selection!\n";
            system("PAUSE");
            Blacksmith();
    }
}

int Shrine()
{
    system("cls");
    PlayerInfo();
    cout <<"Not available yet!\n\n";
    system("pause");
    Town();
}

void Explore()
{
    system("cls");
    PlayerInfo();
    cout <<"Exploring...\n";
    system("pause");
    Menu();
}

void PlayerInfo()
{
    cout <<playerName<<"\t\t\tHealth: "<<playerHPCur<<"/"<<playerHPMax<<"\t\tMana: "<<playerMPCur<<"/"<<playerMPMax
    <<"\nLevel: "<<playerLvl<<"\t\tGold: "<<playerGold<<"\t\tEXP: "<<playerEXP<<"/"<<playerEXPtoLevel<<"\n\n";
}
